var kanjia={
		ok:1,
		//我要参加
		i_want_in:function(){
			var form='<div class="tjbm">'+
						'<div class="tc">'+
							'<p class="miaosu">所填信息不会被公开，仅用于活动兑奖。</p>'+
							'<p>姓名<input id="name" value="" placeholder="请输入您的真实姓名"></p>'+
							'<p>手机<input id="mobile" value="" placeholder="请输入您的手机号"></p>'+
							'<div class="tj"><a href="javascript:kanjia.join()">提交</a></div>'+
							'<div class="clear"></div>'+
						'</div>'+
					'</div>';
			
			$('.append').html('');
			$('.append').append(form);
		},
		//
		join:function(){
		  name = $('#name').val();
		  mobile = $('#mobile').val();
		  if (!mobile.match(/^((1[3-9]{1}[0-9]{1})+\d{8})$/)) {
			 common.alert('手机号码格式不正确。');return;
		  }
		  kanjia.ok=0;//避免重复提交
		  $.ajax({
             type: "POST",
             data:{"name":name,"mobile":mobile,"act_id":act_id},
             url: "/activity/join/",
             dataType: "json",
             success: function(data){
            	kanjia.ok = 1;
            
                if(data.status){
                	setTimeout(function () {
              		   window.location.href = '/act/'+act_id+'/'+mobile;
                     }, 3000);
                	$('.append').html('');
                	common.alert(data.msg);
                }else{
                	common.alert(data.msg);
                }
              }
           });
		},
		sendfriend:function(){
			$('.append').html('');
		    $('.append').append('<div class="ydfx"><img class="hideme" src="/img/share.png?1"></div>');
		},
		helpcut:function(){
			kanjia.ok=0;
			$.ajax({
			     type: "GET",
			     url: "/activity/helpcut/"+act_id+'/'+help_mobile,
			     dataType: "json",
			     success: function(data){
			    	kanjia.ok = 1;
			    
			        if(data.status){
			        	common.alert(data.msg);
			        	$('.current_price').html("<strong>现价</strong>"+data.data.current_price+"元");
			        }else{
			        	common.alert(data.msg);
			        }
			      }
			 });
		}
}

$(function(){
	$('.join').click(function(){
		kanjia.i_want_in();
	});
	$('.sendfriend').click(function(){
		kanjia.sendfriend();
	});
	$('.helpcut').click(function(){
		kanjia.helpcut();
	});
	
	//全局点击事件
	$(document).bind('click',function(e){ 
		var e = e || window.event; //浏览器兼容性 
		var elem = e.target || e.srcElement; 
		if($(elem).attr('class') == 'tjbm'){
			$('.append').html('');
		}
		if($(elem).attr('class') == 'hideme'){
			$('.append').html('');
		}
	}); 
});